//
// Created by liushuai on 18-8-25.
//

#ifndef EX4_SOLUTION_HPP
#define EX4_SOLUTION_HPP


dfs(int [3][3]M,int []visit,int i)
{
    for(int j = 0;j < M.GetLength(0);j++)
    {
        if(M[i,j] == 1 && visit[j] == 0)
        {
            visit[j] = 1;
            dfs(M,visit,j);
        }
    }
}


int FindCircleNum(int[3,3] M) {
        int N = 3;
        int circle = 0; //朋友圈数
        int[] visit = new int[N];
        for(int i = 0;i < N;i++)
        {
            if(visit[i] == 0) //还没被遍历过
            {
                //dfs(M,visit,i); //使用dfs搜索并标记与其相关的学生
                bfs(M,visit,i);   //使用bfs搜索并标记与其相关的学生
                circle++;
            }
        }
        return circle;
    }
int main()
{
    int [3][3]M = [[1,1,0],[1,1,0],[0,0,1]];
    cout<<FindCircleNum(M)<<endl;
}


#endif //EX4_SOLUTION_HPP
